package com.wlyuan.open.scanner.application.async;

import java.util.concurrent.*;

/**
 * @author lijing
 * @description
 */
public class AsyncOrderThreadUtils {

    private static AsyncOrderThreadUtils instance = null;
    private static Object metux = new Object();
    private ThreadPoolExecutor executor = null;

    private AsyncOrderThreadUtils() {
        //LinkedBlockingQueue 先进先出
        this.executor = new ThreadPoolExecutor(6,
                6, 100, TimeUnit.SECONDS,
                new LinkedBlockingQueue(20000));
    }

    public static AsyncOrderThreadUtils getInstance() {
        if (instance == null) {
            synchronized (metux) {
                if (instance == null) {
                    instance = new AsyncOrderThreadUtils();
                }
            }
        }
        return instance;
    }

    public Future submit(Callable able) {
        return this.executor.submit(able);
    }

    public void excute(Runnable runnable) {
        this.executor.execute(runnable);
    }


}
